﻿using System.Reflection;

namespace Inovout.Descriptor
{
    public class FieldDescriptor : MemberDescriptor, IValueGetter
    {
        private FieldInfo fieldInfo;
        public FieldDescriptor(FieldInfo fieldInfo)
            : base(fieldInfo)
        {
            this.fieldInfo = fieldInfo;
        }

        public void SetValue(object instance, object value)
        {
            fieldInfo.SetValue(instance, value);
        }
        public void SetValue(object value)
        {
            SetValue(null, value);
        }
        public object GetValue()
        {
            return GetValue(null);
        }
        public object GetValue(object instance)
        {
            return fieldInfo.GetValue(instance);
        }
    }
}
